package com.woniuxy.commons.interceptor;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Component
public class InterceptorConfiguration implements WebMvcConfigurer {
    @Resource
    private AuthInterceptor authInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 将拦截器添加到拦截器列表中，拦截器才会生效，同时指定拦截所有请求，因为该拦截器
        // 需要用在多个微服务，是一个通用的拦截器
        registry.addInterceptor(authInterceptor).addPathPatterns("/**");
    }
}
